package ru.lukyanets.transmission.client.action;

import com.google.inject.Inject;
import ru.lukyanets.transmission.client.connection.ConnectionState;
import ru.lukyanets.transmission.client.connection.TransmissionService;

/**
 * @author slukyanets
 */
public abstract class TorrentAction extends AbstractAction {
    /** @noinspection unused*/
    @Inject
    private void bindToConnectionState(TransmissionService transmissionService) {
        setDisabled(!transmissionService.getState().equals(ConnectionState.CONNECTED));
        transmissionService.addListener((o, oldVal, newVal) -> setDisabled(!newVal.equals(ConnectionState.CONNECTED)));
    }
}
